package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RadarSensor;
import com.ruoyi.system.service.IRadarSensorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 雷达传感器数据Controller
 * 
 * @author ruoyi
 * @date 2025-10-28
 */
@RestController
@RequestMapping("/system/radarSensor")
public class RadarSensorController extends BaseController
{
    @Autowired
    private IRadarSensorService radarSensorService;

    /**
     * 查询雷达传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:radarSensor:list')")
    @GetMapping("/list")
    public TableDataInfo list(RadarSensor radarSensor)
    {
        startPage();
        List<RadarSensor> list = radarSensorService.selectRadarSensorList(radarSensor);
        return getDataTable(list);
    }

    /**
     * 导出雷达传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:radarSensor:export')")
    @Log(title = "雷达传感器数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RadarSensor radarSensor)
    {
        List<RadarSensor> list = radarSensorService.selectRadarSensorList(radarSensor);
        ExcelUtil<RadarSensor> util = new ExcelUtil<RadarSensor>(RadarSensor.class);
        util.exportExcel(response, list, "雷达传感器数据数据");
    }

    /**
     * 获取雷达传感器数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:radarSensor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(radarSensorService.selectRadarSensorById(id));
    }

    /**
     * 新增雷达传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:radarSensor:add')")
    @Log(title = "雷达传感器数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RadarSensor radarSensor)
    {
        return toAjax(radarSensorService.insertRadarSensor(radarSensor));
    }

    /**
     * 修改雷达传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:radarSensor:edit')")
    @Log(title = "雷达传感器数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RadarSensor radarSensor)
    {
        return toAjax(radarSensorService.updateRadarSensor(radarSensor));
    }

    /**
     * 删除雷达传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:radarSensor:remove')")
    @Log(title = "雷达传感器数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(radarSensorService.deleteRadarSensorByIds(ids));
    }
}
